{template '_header'}

<style type='text/css' xmlns="http://www.w3.org/1999/html">
    .dd-handle { height: 40px; line-height: 30px}
    .dd-list { width:860px;}
</style>


<div class="page-heading">
    <h2>商品分类</h2>
</div>
<form action="" method="post" class="form-validate">

    <div class="dd" id="div_nestable">
        <ol class="dd-list">

            {loop $category $row}
            {if empty($row['parentid'])}
            <li class="dd-item full" data-id="{$row['id']}">

                <div class="dd-handle" >
                    [ID: {$row['id']}] {$row['name']}
                    <span class="pull-right">

                        <div class='label {if $row['enabled']==1}label-success{else}label-default{/if}'
                             {ifp 'goods.category.edit'}
                             data-toggle='ajaxSwitch'
                             data-switch-value='{$row['enabled']}'
                             data-switch-value0='0|隐藏|label label-default|{php echo merchUrl('goods/category/enabled',array('enabled'=>1,'id'=>$row['id']))}'
                             data-switch-value1='1|显示|label label-success|{php echo merchUrl('goods/category/enabled',array('enabled'=>0,'id'=>$row['id']))}'
                             {/if}
                             >
                             {if $row['enabled']==1}显示{else}隐藏{/if}</div>

                {ifp 'goods.category.edit|goods.category.view'}
                <!--a class='btn btn-default btn-sm' href="{php echo merchUrl('goods/category/edit', array('id' => $row['id']))}" title="{ifp 'goods.category.edit'}修改{else}查看{/if}" ><i class="fa fa-edit"></i></a-->
                {/if}
                </span>
    </div>
    {if count($children[$row['id']])>0}

    <ol class="dd-list">
        {loop $children[$row['id']] $child}
        <li class="dd-item full" data-id="{$child['id']}">
            <div class="dd-handle" style="width:100%;">
                <!--img src="{php echo tomedia($child['thumb']);}" width='30' height="30" onerror="$(this).remove()" style='padding:1px;border: 1px solid #ccc;float:left;' /--> &nbsp;
                [ID: {$child['id']}] {$child['name']}
                                <span class="pull-right">
                                    <div class='label {if $child['enabled']==1}label-success{else}label-default{/if}'
                                         {ifp 'goods.category.edit'}
                                         data-toggle='ajaxSwitch'
                                         data-switch-value='{$child['enabled']}'
                                         data-switch-value0='0|隐藏|label label-default|{php echo merchUrl('goods/category/enabled',array('enabled'=>1,'id'=>$child['id']))}'
                                         data-switch-value1='1|显示|label label-success|{php echo merchUrl('goods/category/enabled',array('enabled'=>0,'id'=>$child['id']))}'
                                         {/if}
                                         >
                                         {if $child['enabled']==1}显示{else}隐藏{/if}</div>

            {ifp 'goods.category.edit|goods.category.view'}<!--a class='btn btn-default btn-sm' href="{php echo merchUrl('goods/category/edit', array('id' => $child['id']))}" title="{ifp 'goods.category.edit'}修改{else}查看{/if}" ><i class="fa fa-edit"></i></a-->{/if}
            </span>
            </div>
            {if count($children[$child['id']])>0 && intval($shopset['catlevel'])==3}

            <ol class="dd-list"  style='width:100%;'>
                {loop $children[$child['id']] $third}
                <li class="dd-item" data-id="{$third['id']}">
                    <div class="dd-handle">
                        <!--img src="{php echo tomedia($third['thumb']);}" width='30' height="30" onerror="$(this).remove()" style='padding:1px;border: 1px solid #ccc;float:left;' /--> &nbsp;
                        [ID: {$third['id']}] {$third['name']}
                                            <span class="pull-right">
						 <div class='label {if $third['enabled']==1}label-success{else}label-default{/if}'
											{ifp 'goods.category.edit'}
											data-toggle='ajaxSwitch'
											data-switch-value='{$third['enabled']}'
											data-switch-value0='0|隐藏|label label-default|{php echo merchUrl('goods/category/enabled',array('enabled'=>1,'id'=>$third['id']))}'
											data-switch-value1='1|显示|label label-success|{php echo merchUrl('goods/category/enabled',array('enabled'=>0,'id'=>$third['id']))}'
											{/if}
											>
											{if $third['enabled']==1}显示{else}隐藏{/if}</div>

                    {ifp 'goods.category.edit|goods.category.view'}<!--a class='btn btn-default btn-sm' href="{php echo merchUrl('goods/category/edit', array('id' => $third['id']))}" title="{ifp 'goods.category.edit'}修改{else}查看{/if}" ><i class="fa fa-edit"></i></a-->{/if}
                    </span>
                    </div>
                </li>
                {/loop}
            </ol>
            {/if}
        </li>
        {/loop}
    </ol>
    {/if}

    </li>
    {/if}
    {/loop}

    </ol>



    </div>

    <div class="col-sm-12">
        <div class='alert alert-info'>
            提示：1. 隐藏的分类,在商户店铺的分类中将不会显示<br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2. 如要增加分类,请联系平台添加
        </div>
    </div>

</form>

<script language='javascript'>
    myrequire(['jquery.nestable'], function () {
        $('.dd-item').addClass('full');
    })
</script>

{template '_footer'}

